This invention relates to disk drivers and, more particularly, to the use of a memory buffer during disk drive operations.
In a computer system, a device driver is a software program that controls a hardware device. A computer system with a keyboard, a mouse, and a hard disk drive, for example, may include a keyboard driver, a mouse driver, and a hard disk driver.
In a personal computer-based system, device drivers typically interface between other software programs and the device controlled by the device driver. An operating system usually includes a variety of device drivers, although new device drivers may be loaded into the computer system, such as when loading a new hardware device.
The operating system works in conjunction with the device driver for a specific device to service a request. For example, when a user directs the operating system to xe2x80x9cloadxe2x80x9d or xe2x80x9cexecutexe2x80x9d an application program, the application program is typically stored on the hard disk drive. The xe2x80x9cloadingxe2x80x9d of the application program is essentially a request to read the application program from the hard disk drive and to write the program into a memory. The application program may then run from the memory.
The operating system thus sends the read request to a disk driver which services the hard disk drive. The disk driver translates the xe2x80x9cload application programxe2x80x9d command into a hard disk drive command, to retrieve the data from the location where the application is stored. For example, the disk driver may issue a xe2x80x9cread sectorsxe2x80x9d command, identifying both where the application program is stored on the hard disk drive as well as to where in memory the application program is to be transferred. The disk driver thus acts as a translator between the requesting program and the hard disk drive. Write operations, which transfer from the memory to the hard disk drive, operate similarly.
Whether for read or write operations, disk drive accesses are typically substantially slower than memory accesses. Therefore, in addition to translating the particular software request, a disk driver may allocate a portion of memory, sometimes known as a cache or a buffer, to reduce the number of hard disk drive accesses and thus improve system performance.
For example, when a read request for a particular sector or group of sectors is made, the disk driver may xe2x80x9cprefetchxe2x80x9d additional, unrequested sectors into the buffer portion of the memory. The prefetching anticipates that subsequent requests will be made for these as yet unrequested sectors.
For a write operation, buffer may be used to store write data. Again, to minimize the number of hard disk drive accesses, the disk driver may store data for a number of write operations in the memory buffer. Then, at a later time, the disk driver may perform a single write operation to the hard disk drive to fulfill all the write requests at once.
The disk driver, however, may not always predict which future hard disk drive requests may occur. In some cases, attempts to optimize performance may backfire. A number of prefetched sectors which are never retrieved from the memory actually may diminish performance. This is because it took time to retrieve the additional non-used sectors. Likewise, a buffered write which is not soon combined with another write merely delays the intended write to the hard disk drive, creating the risk that the data could be lost, such as if power is unintentionally removed from the computer system.
Thus, there is a continuing need for a disk driver which improves performance of either or both of the read prefetch and write buffer operations.